import { http } from '@/utils/http'
import type { TeacherItem, TeacherParams } from '@/types/teacher'
import type { PageResult } from '@/types/global'

/**
 * 获取教师列表
 * @param data
 * @returns
 */
export const getTeacherListAPI = (data?: TeacherParams) => {
  return http<PageResult<TeacherItem>>({
    method: 'GET',
    url: '/wechat/teacher/list',
    data,
  })
}

/**
 * 获取教师详情
 * @param id
 * @returns
 */
export const getTeacherDetailAPI = (id: number) => {
  return http<TeacherItem>({
    method: 'GET',
    url: `/wechat/teacher/${id}`,
  })
}

/**
 * 添加教师
 * @param data
 * @returns
 */
export const addTeacherAPI = (data: Omit<TeacherItem, 'id' | 'createTime' | 'updateTime'>) => {
  return http<TeacherItem>({
    method: 'POST',
    url: '/wechat/teacher/add',
    data,
  })
}

/**
 * 更新教师
 * @param id
 * @param data
 * @returns
 */
export const updateTeacherAPI = (id: number, data: Partial<TeacherItem>) => {
  return http<TeacherItem>({
    method: 'POST',
    url: `/wechat/teacher/update`,
    data,
  })
}
